﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using CoolCode;
using CoolCode.Linq;
using CoolCode.Search;
using CoolCode.Web.Syndication;
using XNoteBook.Entities;
using XNoteBook.Models;

namespace XNoteBook.Services
{
	public interface IPostService
	{
		void DeleteCategory(string id);
		void DeleteNode(string id);
		void DeletePost(string id);

		Category GetCategory(string id);
		int GetMaxSortIndex(string parentID);
		NodeListModel GetChildrenNodes(string parentID);
		NodeListModel GetCategories(string parentID);
		Post GetPost(string id);
		IEnumerable<NodeModel> GetSelfAndForefathers(string id);

		List<Post> ListPost();
		//IPaginatedList<Post> PagingPost(PageParam p);
		IPageable<Post> PagingPost(PageParam p);
		IQueryable<Post> QueryPost();
		IQueryable<NodeModel> QueryNode(IQueryBuilder<NodeModel> condition);

		string MoveNode(TreeCategory entity, bool copy);
		void RenameCategory(Category entity);
		void RenameNode(NodeModel entity);

		void SaveCategory(Category entity, string parentID, int position);
		void SavePost(Post entity, string parentID);
		void SavePost(Post entity);
		string SaveNode(NodeModel entity);

		void UpdatePost(string id, Expression<Func<Post,Post>> update);

		void ViewPost(string id, string user);

		IPaginatedList<SearchResult> Search(string q, int page, ILinqSearchEngine searchEngine, Func<Post, string> buildeUrl);
		FeedModel Rss();

		/// <summary>
		/// 最常浏览的
		/// </summary>
		/// <returns></returns>
		TopTenModel ListTop10PostsByFrequency();

		/// <summary>
		/// 浏览最多的
		/// </summary>
		/// <returns></returns>
		TopTenModel ListTop10PostsByViews();

		/// <summary>
		/// 最新的
		/// </summary>
		/// <returns></returns>
		TopTenModel ListTop10PostsByDate();

		void Import(PostOuterInfoModel model, string userID);

		IQueryable<PostOuterInfo> QueryPostOuterInfo(IQueryBuilder<PostOuterInfo> condition);

		PostOuterInfoModel GetPostOuterInfoModel(string id);

		void DeletePostOuterInfo(string id);
	}
}
